<template>
  <div class="healthScoreBar">
    <!--头部标题及颜色label-->
    <div class="healthScoreBarHeader">
      <span class="healthScoreBarTitle">子系统健康评分柱状图</span>
      <span class="colorIndex" style="background-color: #58CEA0;"></span>
      <span class="labelIndex">当前评分</span>
      <span class="colorIndex" style="background-color: #0081E2;"></span>
      <span class="labelIndex">历史评分</span>
    </div>
    <!--分割线-->
    <el-divider style="margin: 0;"></el-divider>
    <!--柱状图-->
    <div id="scoreBarPic" style="width: 832px; height: 526px;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts';

// todo 根据数据动态变化

export default {
  name: "HealthScoreBar",
  data() {
    return {
      picOption: {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          left: '6%',
          right: '4%',
          bottom: '8%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            axisLine: {
              show: true,
              lineStyle: {
                color: '#1C284B'
              }
            },
            axisLabel: {
              show: true,
              fontsize: '10',
              color: '#999',
            },
            data: [
              '控制系统',
              '牵引系统',
              '辅助系统',
              '制动系统',
              '弓网系统',
              '走行部'
            ],
            axisTick: {
              alignWithLabel: true
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            splitLine: {
              show: true,
              lineStyle: {
                color: '#1C284B'
              }
            },
            splitNumber: 10,
            axisTick: {
              show: true
            },
            axisLabel: {
              // formatter: ['10分', '20分', '30分', '40分', '50分', '60分', '70分', '80分', '90分',  '100分'],
              show: true,
              fontsize: '10',
              color: '#999',
              margin: 15
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: '#1C284B'
              }
            }
          }
        ],
        series: [
          {
            name: '历史评分',
            type: 'bar',
            barWidth: '10%',
            data: [10, 20, 60, 33, 39, 33, 100],
            itemStyle: {
              color: '#0081E2'
            }
          },
          {
            name: '当前评分',
            type: 'bar',
            barWidth: '10%',
            data: [10, 52, 20, 34, 39, 30, 100],
            itemStyle: {
              color: '#58CEA0'
            }
          }
        ]
      }
    }
  },
  mounted() {
    this.barPic = echarts.init(document.getElementById("scoreBarPic"));
    this.barPic.setOption(this.picOption);
  }
}
</script>

<style>

</style>

<style scoped>
.healthScoreBarHeader {
  width: 834px;
  height: 62px;
}
.healthScoreBarTitle {
  width: 200px;
  height: 62px;
  color: #aaa;
  font-size: 20px;
  line-height: 62px;
  margin-left: 26px;
  margin-right: 400px;
  padding-bottom: 17px;
  border-bottom: 3px solid #0081E2;
}
.colorIndex {
  padding:0 8px;
  margin-right: 7px;
}
.labelIndex {
  color: #999;
  font-size: 14px;
  margin-right: 24px;
}
</style>
